package com.jt.controller;

import com.jt.pojo.Item;
import com.jt.pojo.ItemDesc;
import com.jt.vo.EasyUITable;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jt.service.ItemService;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/item")
public class ItemController {
	
	@Autowired
	private ItemService itemService;

	//分页查询商品信息
	@RequestMapping("/query")
	public EasyUITable findItemByPage(int page,int rows){
		return itemService.findItemByPage(page,rows);
	}

	//新增商品
	@RequestMapping("/save")
	public SysResult saveItem(Item item, ItemDesc itemDesc){
		itemService.saveItem(item,itemDesc);
		return SysResult.success();
	}

	//修改商品信息
	@RequestMapping("/update")
	public SysResult updateItem(Item item,ItemDesc itemDesc){
		itemService.updateItem(item,itemDesc);
		return SysResult.success();
	}

	//根据商品id删除商品
	@RequestMapping("delete")
	public SysResult deleteItem(Long[] ids){
		itemService.deleteItem(ids);
		return SysResult.success();
	}

	//商品上架、 下架
	@RequestMapping("/updateStatus/{status}")
	public SysResult updateStatus(@PathVariable Integer status,Long[] ids){
		itemService.updateStatus(status,ids);
		return SysResult.success();
	}


	
}
